import subprocess
import os
import datetime

# 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__))

# 定义要运行的脚本的完整路径
script_path = os.path.join(current_dir, "首板战法.py")


# 定义日志文件路径
log_file_path = os.path.join(current_dir, "log/首板战法")


# 启动自定义的子进程
processes = []
for _ in range(15):
    p = subprocess.Popen(['/home/stock/python/bin/python', script_path])

try:
    # 等待直到所有子进程结束
    for process in processes:
        process.wait()
except KeyboardInterrupt:
    # 当收到中断信号时，终止所有子进程
    print("Interrupt signal received. Terminating processes...")
    for process in processes:
        process.terminate()
